﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArithmeticLibrary.Tree
{
    /// <summary>
    /// Trida reprezentujici
    /// </summary>
    public class VariableNode : LeafNode
    {
        #region Fields

        /// <summary>
        /// Jmeno promenne.
        /// </summary>
        private readonly string name;

        #endregion

        #region Properties

        /// <summary>
        /// Vrati jmeno promenne.
        /// </summary>
        public string Name { get { return name; } }

        #endregion // Properties

        #region Constructors

        /// <summary>
        /// Vytvori instanci uzlu promenne.
        /// </summary>
        /// <param name="name">Jmeno promenne.</param>
        public VariableNode(string name)
        {
            this.name = name;
        }

        #endregion // Constructors

        /// <summary>
        /// Vyhodnoti promennou.
        /// </summary>
        /// <returns></returns>
        public override double Evaluate(double x)
        {
            return x;
        }

        public override R Accept<R, C>(IExpressionVisitor<R, C> visitor, C context)
        {
            return visitor.Visit(this, context);
        }
    }
}
